class Solution {
public:
    string countAndSay(int n) {
        return digui(n);
    }
    string digui(int n){
        if(n==1){return "1";}
        string cur=digui(n-1);
        string res;
        int idx=0,len=cur.length();
        while(idx<len){
            char st=cur[idx];
            int tmp_idx=idx;
            while(idx<len){
                idx=idx+1;
                if(idx>=len){break;}
                char temp=cur[idx];
                if(temp!=st){break;}
            }
            res+=to_string(idx-tmp_idx)+st;
        }
        return res;
    }
};